﻿@model CodeBox.FB.ViewModels.TeamInfoModel
@{
    ViewBag.Title = "New";
}
<h2>
    New</h2>
<script type="text/javascript" language="javascript">
    $(document).ready(function () {

        //check name already existing.
        $("#TeamName").change(function () {
            $.ajax({
                url: 'Team/IsValid/' + $(this).val(),
                type: "POST",
                success: function (data) {
                    showTeamInfo(data);
                    alert(data);
                },
                error: function (xhr, ajaxOptions, thrownError) {
                     alert(xhr.status);
                    alert(thrownError);
                },
                complete: function () {
                    alert('complete');
                }
            });
        });
    });
</script>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>New Team</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.TeamName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.TeamName)
            @Html.ValidationMessageFor(model => model.TeamName)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.ImageUrl)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ImageUrl)
            @Html.ValidationMessageFor(model => model.ImageUrl)
        </div>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}
<div>
    @Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
